import React from 'react';
import classNames from 'classnames';

import {
  Modal,
  Button
} from 'react-bootstrap';

class DialogCommon extends React.Component {

  constructor() {
    super();
  }

  static propTypes = {
    title : React.PropTypes.string,
    content : React.PropTypes.element,
    buttons: React.PropTypes.array,
    onHide : React.PropTypes.func
  }

  static defaultProps = {
    title : "系统提示",
    content : "",
    buttons : [{
      text : "确定"
    }]
  }

  render() {

    let { title, content, buttons, onHide,  visiable, ...other} = this.props;

    return (
        <Modal show={visiable} onHide = { onHide } {...other}>
          <Modal.Header>
            <Modal.Title>
                { title }
            </Modal.Title>
          </Modal.Header>
          <Modal.Body>
            {content}
          </Modal.Body>
          <Modal.Footer>

            { buttons && buttons.map((button, index) => {
                let callback = button.callback || onHide;
                let bzStyle = button.style || "info";
                return (
                  <Button onClick={ callback } bsStyle={ bzStyle }>
                    { button.text }
                  </Button>  
                );
            })}
            
          </Modal.Footer>
        </Modal>
    );
  }
}

export default DialogCommon;
